function [y, T, residual, g1] = static_2(y, x, params, sparse_rowval, sparse_colval, sparse_colptr, T)
residual=NaN(6, 1);
  T(1)=y(2)^(1-y(10));
  T(2)=log(y(2));
  T(3)=(y(10)-1)^2;
  T(4)=T(1)*T(2)/(y(10)-1)+(T(1)-1)/T(3);
  T(5)=y(2)^(-y(10));
  residual(1)=(T(5)+params(4)*params(8)*T(4)*params(1)*y(1)/y(3))-(T(5)*params(1)*(1-params(3)+params(4)*y(1)/y(3)));
  residual(2)=(y(10))-(params(6)-params(8)*(y(1)-params(9)));
  residual(3)=(y(2)+y(4))-(y(1));
  T(6)=y(3)^params(4);
  T(7)=exp(y(7));
  T(8)=T(6)*T(7);
  T(9)=y(5)^(1-params(4));
  residual(4)=(y(1))-(T(8)*T(9));
  residual(5)=(y(4))-(y(3)-y(3)*(1-params(3)));
  residual(6)=((params(4)-1)*params(8)*y(1)/y(5)*T(4))-(params(2)*y(5)^params(7)+(params(4)-1)*y(1)/y(5)*T(5));
  T(10)=getPowerDeriv(y(2),1-y(10),1);
  T(11)=getPowerDeriv(y(2),(-y(10)),1);
  T(12)=((y(10)-1)*T(2)*T(1)*(-T(2))-T(1)*T(2))/((y(10)-1)*(y(10)-1))+(T(3)*T(1)*(-T(2))-(T(1)-1)*2*(y(10)-1))/(T(3)*T(3));
if nargout > 3
    g1_v = NaN(18, 1);
g1_v(1)=params(4)*params(8)*T(4)*params(1)*(-y(1))/(y(3)*y(3))-T(5)*params(1)*params(4)*(-y(1))/(y(3)*y(3));
g1_v(2)=(-(T(9)*T(7)*getPowerDeriv(y(3),params(4),1)));
g1_v(3)=(-(1-(1-params(3))));
g1_v(4)=T(5)*(-T(2))+y(1)/y(3)*params(4)*params(8)*params(1)*T(12)-(1-params(3)+params(4)*y(1)/y(3))*params(1)*T(5)*(-T(2));
g1_v(5)=1;
g1_v(6)=(params(4)-1)*params(8)*y(1)/y(5)*T(12)-(params(4)-1)*y(1)/y(5)*T(5)*(-T(2));
g1_v(7)=params(4)*params(8)*T(4)*params(1)*1/y(3)-T(5)*params(1)*params(4)*1/y(3);
g1_v(8)=params(8);
g1_v(9)=(-1);
g1_v(10)=1;
g1_v(11)=T(4)*(params(4)-1)*params(8)*1/y(5)-T(5)*(params(4)-1)*1/y(5);
g1_v(12)=(-(T(8)*getPowerDeriv(y(5),1-params(4),1)));
g1_v(13)=T(4)*(params(4)-1)*params(8)*(-y(1))/(y(5)*y(5))-(params(2)*getPowerDeriv(y(5),params(7),1)+T(5)*(params(4)-1)*(-y(1))/(y(5)*y(5)));
g1_v(14)=1;
g1_v(15)=1;
g1_v(16)=T(11)+y(1)/y(3)*params(4)*params(8)*params(1)*((T(2)*T(10)+T(1)*1/y(2))/(y(10)-1)+T(10)/T(3))-(1-params(3)+params(4)*y(1)/y(3))*params(1)*T(11);
g1_v(17)=1;
g1_v(18)=(params(4)-1)*params(8)*y(1)/y(5)*((T(2)*T(10)+T(1)*1/y(2))/(y(10)-1)+T(10)/T(3))-(params(4)-1)*y(1)/y(5)*T(11);
    if ~isoctave && matlab_ver_less_than('9.8')
        sparse_rowval = double(sparse_rowval);
        sparse_colval = double(sparse_colval);
    end
    g1 = sparse(sparse_rowval, sparse_colval, g1_v, 6, 6);
end
end
